import Service from '../../core/baseService';

export default class UserService extends Service {
  constructor(ctx) {
    super(ctx);
    this.model = this.ctx.model.MUser;
  }

  async create(data) {
    const result = await this.model.create(data);
    return result;
  }

  async destroy(id) {
    const result = await this.model.remove({
      _id: id,
    });

    return result;
  }

  async update(user_id, data) {
    try {
      return await this.model
        .update(
          {
            ...data,
          },
          {
            where: {
              user_id
            }
          }
        )
    } catch (err: any) {
      this.ctx.logger.error(err.message);
      return '';
    }
  }
}
